﻿namespace GalaxyEngine.Ui.Widgets
{
    using System;
    using System.Web.Mvc;

    public class Editor : IWidget
    {
        private string style;
        private string id;
        private string @class;

        public void SetModel(object model)
        {
            
        }

        public Editor(string id, string @class)
        {
            this.id = id;
            this.@class = @class;
        }

        public string ToHtml()
        {
            TagBuilder builder = new TagBuilder(Resources.Div);
            builder.MergeAttribute("data-dojo-type", "dijit.Editor");
            if (this.id != null)
            {
                builder.MergeAttribute("id", id);
            }

            if (this.@class != null)
            {
                builder.MergeAttribute("class", this.@class);
            }

            return builder.ToString(TagRenderMode.Normal);
        }

        public string GetScript()
        {
            return string.Format(Resources.Script, "dojo.require('dijit.Editor');");
        }

        public void SetStyle(string style)
        {
            this.style = style;
        }

        public string GetStyle()
        {
            return string.Format(Resources.ScriptCss, @class, style);
        }
    }
}
